Ext.define('Zm.view.model.List',{
    extend:'Ext.grid.Panel',
    alias:'widget.modellist',
    uses:['Ext.PagingToolbar','Zm.store.DevDef','Ext.selection.CheckboxModel',
        'Zm.Common','Zm.i18n.Lang','Ext.grid.plugin.DragDrop'
    ],
    store:'DevDef',
    initComponent: function(){
        var me = this,
            lang = Zm.i18n.Lang;
        me.groupId = -1;
        Ext.apply(me,{
            multiSelect:true,
            selModel:{
                listeners:{
                    selectionchange:{
                        fn:me.onSelChange,
                        scope:me
                    }
                }
            },
            selType:'checkboxmodel',
            columns:[
                {text:lang.tId,dataIndex:'ddid'},
                {text:lang.tDdname,dataIndex:'ddname'},
                {text:lang.tModelUrl,dataIndex:'modelurl'},
                {text:lang.tMemo,dataIndex:'memo',flex:1}
            ],
            viewConfig:{
                plugins:{
                    ptype: 'gridviewdragdrop',
                    dragGroup:'ddGroup'
                }
            },
            dockedItems: [{
                xtype:'toolbar',
                dock:'top',
                items:[{
                    text:lang.tAdd,
                    iconCls:'modadd',                
                    action:'add'
                },{
                    text:lang.tEdit,
                    iconCls:'modedit',
                    itemId:'edtbtn',
                    disabled: true,
                    action:'edit'
                },{
                    text:lang.tDel,
                    iconCls:'moddel',
                    itemId:'delbtn',
                    disabled: true,
                    action:'del'
                },'-',lang.tSearch,{
                    xtype:'textfield',
                    itemId:'keyword',
                    enableKeyEvents:true
                }]
            },{
                xtype: 'pagingtoolbar',
                store: me.store,
                dock: 'bottom',
                displayInfo: true
            }]
        });
        me.callParent(arguments);
    },
    onSelChange: function(selModel, selections){
        var me = this,
            bDisabled = selections.length === 0;
        me.down('#edtbtn').setDisabled(bDisabled);
        me.down('#delbtn').setDisabled(bDisabled);
    },
    setCatalog:function(cid){
        var me = this,
            proxy = me.store.getProxy();
        me.groupId = cid;
        proxy.extraParams = {cid:cid};
        me.store.loadPage(1);
    }
});